/**
 * Copyright 2014-2020  the original author or authors.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.upb.webserver.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * 配置类型，注意：可新增，但不要轻易改动，这里的id和name会显示在页面。
 */
@Getter
@ToString
@AllArgsConstructor
public enum ConfigTypeEnum {
    FABRIC_CHAIN_VERSION(1, "fabric链版本"),
    FISCO_CHAIN_VERSION(2, "fisco链版本"),
    SSH_PUBLIC_KEY(3, "ssh公钥"),
    FABRIC_CONSENSUS_TYPE(4, "fabric支持的共识类型"),
    ;

    private byte id;
    private String name;

    ConfigTypeEnum(int id, String name) {
        this.id = (byte) id;
        this.name = name;
    }

    /**
     * @param id
     * @return
     */
    public static ConfigTypeEnum getById(int id) {
        for (ConfigTypeEnum value : ConfigTypeEnum.values()) {
            if (value.id == id) {
                return value;
            }
        }
        return null;
    }
}
